//公共js
//alert(1);


//返回str消毒之后的str
var xxs=function(str){
	var shuzu=['script','on'];
		for (var a in shuzu) {
			var reg=new RegExp(shuzu[a],"gi");
			str=str.replace(reg,"0");
		}
	return str;
}

//判断指定str是否有毒
var is_xxs=function(str){
	if(str!=xxs(str)){
		return true;	//有毒
	}
	return false;
}

//返回str消毒之后的str to加强版
var xxs2=function(str){
	var shuzu=['<','>','script','on'];
		for (var a in shuzu) {
			var reg=new RegExp(shuzu[a],"gi");
			str=str.replace(reg,"0");
		}
	return str;
}

//判断指定str是否有毒 to加强版
var is_xxs2=function(str){
	if(str!=xxs2(str)){
		return true;	//有毒
	}
	return false;
}



/** 验证表单是否已经全部填写 */
var chickform=function(selected){
	var b=true;
	$(":text,:password",selected).each(function(){
		if($(this).val()==""){
			return b=false;
		}
	})
	return b;
}

/** 扩展$.post，使其追加一个异常函数功能 */
$.post2=function(url,data,success,error){
	$.ajax({type:"post",url:url,data:data,dataType:'JSON',
		success:function(data){success(data);},
		error:function(e,ee,eee){error(e,ee,eee);}
	});
}


//为layer追加一个异常专用弹窗
layer.error=function(msg){
	layer.msg(msg,{icon:5,anim:6});
}

//为一个DOM里的值加x
var domAddX=function(dom,x){
	var num=$(dom).html();
	$(dom).html(parseInt(num)+x);
}



//业务相关

//为一个dom增加跳动动画
var tiaodong=function(dom){
	$(dom).removeClass('layui-anim-scale');
	setTimeout(function(){
		$(dom).addClass('layui-anim layui-anim-scale');
	},0)
}

//为帖子点赞、踩、或举报
var pzan=function(dom,way){
	if(way==3){
		if(confirm("举报此帖子？")==false){
			return;
		}
	}
	
	tiaodong(dom);
	
	var pid=$(dom).parent().parent().children("[name=pid]").val();
	$.post2("../post/doPostZC.ajax",{pid:pid,way:1},function(data){
		if(data.res==-1){layer.msg("请求不合法");}
		if(data.res==-2){layer.msg("歇会儿，同一帖子只能点赞/踩/举报一次");}
		if(data.res==1){
			$(dom).css("color","red");
			var num=$(dom).children("span").html();
			$(dom).children("span").html(parseInt(num)+1);
		}
	},function(e,ee,eee){
		layer.msg("请求失败"+eee)
	})
	
}



//业务整装待发
$(function(){
	
	var txs=[
		{lv:1,exp:0,title:'潜水'},
		{lv:2,exp:50,title:'冒泡'},
		{lv:3,exp:150,title:'活跃'},
		{lv:4,exp:300,title:'传说'},
		{lv:5,exp:500,title:'王者'},
		{lv:6,exp:800,title:'小神'},
		{lv:7,exp:1200,title:'大神'},
		{lv:8,exp:2000,title:'仙'},
		{lv:9,exp:5000,title:'奶茶'},
		{lv:10,exp:10000,title:'我爱你'},
		{lv:11,exp:20000,title:'我就不信有人能升到这个头衔！'}
	]
	
	$('.usee_tx').each(function(){
		
		var ujf=parseInt($(this).html());
		var tx='潜水';
		
		$(txs).each(function(){
			if(ujf>this.exp){
				tx=this.title;
			}
		})
		
		$(this).html(tx);
	})
	
	
	
})












//响应式相关



